package com.xuwang.service.impl;

import com.xuwang.Common.Constast;
import com.xuwang.Util.TableResult;
import com.xuwang.mapper.RestaurantSupervisionMapper;
import com.xuwang.pojo.RawMaterialSupplier;
import com.xuwang.pojo.Restaurant;
import com.xuwang.service.RestaurantSupervisionService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ Author  460503919
 * @ Date    2021/9/17 10:43
 * @ VERSION 1.0.0
 */
@Service
public class RestaurantSupervisionServiceImpl implements RestaurantSupervisionService {

    @Resource
    private RestaurantSupervisionMapper restaurantSupervisionMapper;

    /**
     * 查询餐馆原材料
     *
     * @param id
     * @return
     */
    @Override
    public TableResult<Restaurant> showSupervision(Integer id) {
        TableResult<Restaurant> result;
        //供货商列表
        Restaurant restaurantList = restaurantSupervisionMapper.showSupervision(id);
        //餐馆原材料列表
        List<RawMaterialSupplier> rawMaterialSupplierList = restaurantList.getRawMaterialSupplier();
        if (rawMaterialSupplierList.size() > 0) {
            result = new TableResult<>(200, "查询原材料成功", rawMaterialSupplierList.size(), restaurantList);
        } else if (rawMaterialSupplierList.size() == 0) {
            result = new TableResult<>(200, "该餐馆暂未更新原材料信息", 0, restaurantList);
        } else {
            result = new TableResult<>(200, Constast.ADMIN_NULL, 0, restaurantList);
        }
        return result;
    }

    /**
     * 获取消毒记录
     *
     * @param id
     * @return
     */
    @Override
    public TableResult<Restaurant> showDisinfect(Integer id) {
        TableResult<Restaurant> result;
        Restaurant restaurantList = restaurantSupervisionMapper.showDisinfect(id);
        result=new TableResult<>(200,"获取消毒记录成功",restaurantList.getDisinfectList().size(),restaurantList);
        return result;
    }
}
